<?php
interface IJisuanqi{
	function jisuan($x, $y);
}
class Jia implements IJisuanqi {
	function jisuan($x, $y) {
		return $x . "+" . $y . "=" . ($x + $y);
	}

}

class Jian implements IJisuanqi {
	function jisuan($x, $y) {
		return $x . "-" . $y . "=" . ($x - $y);
	}

}

class Cheng implements IJisuanqi {
	function jisuan($x, $y) {
		return $x . "*" . $y . "=" . ($x * $y);
	}

}

class Chu implements IJisuanqi {
	function jisuan($x, $y) {
		return $x . "/" . $y . "=" . ($x / $y);
	}

}

class Yu implements IJisuanqi {
	function jisuan($x, $y) {
		return $x . "%" . $y . "=" . ($x % $y);
	}

}

class Gongcahng {
	static function createobject($str) {
		//PHP默认是多态
		if (class_exists($str)) {
			return new $str();
		} else {
			return new Jia();
		}
	}

}

$str = Gongcahng::createobject("Chu");
echo $str -> jisuan(10, 2);
?>